<template>
  <MyVanskeleton :loading="skeletonLoading">
    <template v-slot:my-content>
      <div class="company-style">
        <!-- 内容 start -->
        <div class="my-index">
          <!-- 基本信息 -->
          <div class="basic">
            <p class="logo" @click="onLogo">
              <sub>上传LOGO</sub>
              <img src="@/assets/img/company/firm_default_avatar.png" alt="" v-if="responseData.companyLogo==''" />
              <img :src="responseData.companyLogo" alt="" v-else />
            </p>
            <p class="info" @click="onCompanyName">
              <b>{{responseData.companyName}}</b>
              <span>{{responseData.expireDays}}</span>
            </p>
          </div>

          <!-- 数据统计 -->
          <ul class="data">
            <li @click="$router.push({ name: 'company-my-invite'})">
              <b>{{responseData.faceCount}}</b>
              <span>面试日程</span>
            </li>
            <!-- <li>
              <b>26</b>
              <span>企业问答</span>
            </li> -->
            <!-- <li>
          <b>5</b>
          <span>浏览足迹</span>
        </li> -->
          </ul>

          <!-- 招聘必备 -->
          <dl class="tool">
            <dt>招聘必备</dt>
            <dd>
              <p @click="$router.push({name:'company-my-info'})">
                <van-image width="22" height="22" :src="require('@/assets/img/company/my/my-firm-ico.png')" />
                <span>企业信息</span>
              </p>

              <p @click="$router.push({name:'company-poster-jobsel'})">
                <van-image width="22" height="22" :src="require('@/assets/img/company/my/my-poster-ico.png')" />
                <span>招聘海报</span>
              </p>

              <p @click="$router.push({name:'company-my-photos'})" v-if="false">
                <van-image width="22" height="22" :src="require('@/assets/img/company/my/my-photo-ico.png')" />
                <span>企业相册</span>
              </p>

              <p @click="$router.push({name:'company-my-serviceindex'})" v-if="false">
                <van-image width="22" height="22" :src="require('@/assets/img/company/my/my-store-ico.png')" />
                <span>增值服务</span>
              </p>
              <p v-if="false" @click="$router.push({name:'company-my-wallet',query:{rcdCnt:responseData.rcdCount}})">
                <van-image width="22" height="22" :src="require('@/assets/img/company/my/my-asset-ico.png')" />
                <span>我的钱包</span>
              </p>
              <!-- <p>
                <van-image width="22" height="22" :src="require('@/assets/img/company/my/my-data-ico.png')" />
                <span>招聘数据</span>
              </p> -->

              <p v-if="false" @click="$router.push({name:'company-my-membership'})">
                <van-image width="22" height="22" :src="require('@/assets/img/company/my/my-invoice-ico.png')" />
                <span>开发票</span>
              </p>
            </dd>
          </dl>

          <!-- 我的资产 -->
          <dl class="asset">
            <dt>
              <b>我的资产</b>
              <span v-if="false" @click="$router.push({name:'company-my-serviceindex',query:{tabIndex:1}})">购买</span>
            </dt>
            <dd>
              <p>
                <b>{{responseData.stationCount}}</b>
                <span>职位数(个)</span>
              </p>
              <p>
                <b>{{responseData.resumeCount}}</b>
                <span>简历数(份)</span>
              </p>
              <!-- <p>
                <b>{{responseData.smsCount}}</b>
                <span>短信数(条)</span>
              </p> -->
              <p>
                <b>{{responseData.rcdCount}}</b>
                <span>人才点(点)</span>
              </p>
            </dd>
          </dl>

          <!-- 其他功能 -->
          <dl class="tool">
            <dt>其他</dt>
            <dd>
              <p @click="$router.push({name:'company-my-membership'})" v-if="false">
                <van-image width="22" height="22" :src="require('@/assets/img/company/my/my-service-ico.png')" />
                <span>专属客服</span>
              </p>
              <p @click="$router.push({name:'company-feedback'})">
                <van-image width="22" height="22" :src="require('@/assets/img/company/my/my-feedback-ico.png')" />
                <span>意见反馈</span>
              </p>
              <p @click="onPerson">
                <van-image width="22" height="22" :src="require('@/assets/img/company/my/my-identity-ico.png')" />
                <span>我要求职</span>
              </p>
              <p @click="$router.push({name:'company-my-settingindex'})">
                <van-image width="22" height="22" :src="require('@/assets/img/company/my/my-setting-ico.png')" />
                <span>设置</span>
              </p>
            </dd>
          </dl>
        </div>
        <!-- 内容 end -->
      </div>
    </template>
  </MyVanskeleton>
</template>

<script>
import { Image as VanImage, Dialog, Toast } from "vant";
import MyMixin from '@/mixin/MyMixin';
import { returnToPhoneWithData } from '@/util/phone';
import { getCompanyID, getToken } from '@/util/session';
import Global from '@/Global';
export default {
  name: "LoginPage",
  components: {
    [VanImage.name]: VanImage,
  },
  // 定义属性
  data() {
    return {
      skeletonLoading: true,
      responseData: {}
    };
  },
  mixins: [MyMixin],
  mounted() {
    this.loadData();
    window.uploadCallback = this.uploadCallback;
  },
  // 方法集合
  methods: {
    loadData() {
      this.$api.get('/CompanyMine/GetMineData').then(res => {
        this.skeletonLoading = false;
        if (res.success) {
          this.responseData = res.response;
        }
      })
    },
    onCompanyName() {
      this.$router.push({ name: 'company-my-member', query: { companyIDEncrypt: this.responseData.companyIDEncrypt } })
    },
    onPerson() {
      Dialog.confirm({ message: "确认切换为个人求职？" }).then(() => {
        this.switchUser('P');
      })
    },
    onLogo() {
      returnToPhoneWithData({ action: 'company_upload_logo', token: getToken() })
    },
    //上传logo回调
    uploadCallback(imgUrl) {
      this.responseData.companyLogo = imgUrl + '?v=' + new Date();
    }
  },
};
</script>

<style lang="less">
@import "vant/lib/index.less";
@import "@/assets/css/company.less";
</style>